﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/MenuMaster.Master" AutoEventWireup="true"
    CodeBehind="ViewAllDynamicContent.aspx.cs" Inherits="Department.admin.Content.ViewAllDynamicContent" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
 <h1> <asp:HyperLink ID="addHyperLink" NavigateUrl="~/admin/Content/AddDynamicContent.aspx" CssClass="sub_show" runat="server">Добави динамично съдържание</asp:HyperLink></h1>
     <br />
    <div id="page-heading">
        <h1>
            Всички динамични съдържания</h1>
    </div>
    <!-- end page-heading -->
    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
            <th rowspan="3" class="sized">
                <img src="../images/shared/side_shadowleft.jpg" width="20" height="300" alt="" />
            </th>
            <th class="topleft">
            </th>
            <td id="tbl-border-top">
                &nbsp;
            </td>
            <th class="topright">
            </th>
            <th rowspan="3" class="sized">
                <img src="../images/shared/side_shadowright.jpg" width="20" height="300" alt="" />
            </th>
        </tr>
        <tr>
            <td id="tbl-border-left">
            </td>
            <td>
                <!--  start content-table-inner ...................................................................... START -->
                <div id="content-table-inner">
                    <!--  start table-content  -->
                    <div id="table-content">
                        <asp:SqlDataSource ID="itemsViewDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:DepartmentConnectionString %>"
                            
                            SelectCommand="SELECT DynamicContent.ID, DynamicContent.Name, DynamicContent.Date, DynamicContent.IsHidden, DynamicContent.TypeID, DynamicContent.ID AS Expr1, Type.Name AS TypeName, DynamicContent.FacDeptID FROM DynamicContent INNER JOIN Type ON DynamicContent.TypeID = Type.ID WHERE (DynamicContent.FacDeptID = dbo.uf_get_department_id()) ORDER BY DynamicContent.Date DESC" 
                            DeleteCommand="DELETE FROM [DynamicContent] WHERE [ID] = @ID" 
                            InsertCommand="INSERT INTO [DynamicContent] ([Name], [Date], [IsHidden], [TypeID]) VALUES (@Name, @Text, @Date, @IsHidden, @TypeID)" 
                            
                            
                            UpdateCommand="UPDATE [DynamicContent] SET [Name] = @Name, [Date] = @Date, [IsHidden] = @IsHidden, [TypeID] = @TypeID WHERE [ID] = @ID">
                            <DeleteParameters>
                                <asp:Parameter Name="ID" Type="Int32" />
                            </DeleteParameters>
                            <InsertParameters>
                                <asp:Parameter Name="Name" Type="String" />
                              
                                <asp:Parameter Name="Text" />
                              
                                <asp:Parameter DbType="Date" Name="Date" />
                            
                                <asp:Parameter Name="IsHidden" Type="Boolean" />
                                <asp:Parameter Name="TypeID" Type="Int32" />
                            </InsertParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="Name" Type="String" />
                           
                                <asp:Parameter DbType="Date" Name="Date" />
                              
                                <asp:Parameter Name="IsHidden" Type="Boolean" />
                                <asp:Parameter Name="TypeID" Type="Int32" />
                                <asp:Parameter Name="ID" Type="Int32" />
                            </UpdateParameters>
                        </asp:SqlDataSource>
                        <asp:SqlDataSource ID="typeDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:DepartmentConnectionString %>"
                            SelectCommand="SELECT [ID], [Name] FROM [Type] ORDER BY [ID]"></asp:SqlDataSource>
                        <form id="mainform" action="">
                        <table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
                            <tr>
                                <th class="table-header-check">
                                    <asp:CheckBox ID="toggleall" runat="server" AutoPostBack="True" OnCheckedChanged="toggleall_CheckedChanged" />
                                </th>
                                <th class="table-header-repeat line-left minwidth-1">
                                    <asp:LinkButton ID="sortByName" OnCommand="sortByHeading_Click" CommandArgument="Name"
                                        runat="server">Име</asp:LinkButton>
                                </th>
                               
                                <th class="table-header-repeat line-left minwidth-1">
                                    <asp:LinkButton ID="sortByEventDate" OnCommand="sortByHeading_Click" CommandArgument="Date"
                                        runat="server">Дата</asp:LinkButton>
                                </th>
                              
                                <th class="table-header-repeat line-left">
                                    <asp:LinkButton ID="LinkButton1" OnCommand="sortByHeading_Click" CommandArgument="TypeID"
                                        runat="server">Тип</asp:LinkButton>
                                </th>
                                <th class="table-header-repeat line-left">
                                    <asp:LinkButton ID="sortByIsHidden" OnCommand="sortByHeading_Click" CommandArgument="IsHidden"
                                        runat="server">Скрито</asp:LinkButton>
                                </th>
                                <th class="table-header-options line-left">
                                    <a href="">Действия</a>
                                </th>
                            </tr>
                            <asp:ListView ID="itemsView" runat="server" DataSourceID="itemsViewDataSource" >
                                <ItemTemplate>
                                    <tr style="">
                                        <td>
                                            <asp:CheckBox ID="CheckBoxIsMarked" runat="server" />
                                        </td>
                                        <td>
                                            <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
                                        </td>
                                       
                                        <td>
                                            <asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date", "{0:D}") %>' />
                                        </td>
                                 
                                        <td>
                                            <asp:Label ID="TypeLabel" runat="server" Text='<%# Eval("TypeName") %>' />
                                        </td>
                                        <td>
                                            <asp:CheckBox ID="IsHiddenCheckBox" runat="server" Checked='<%# (DataBinder.Eval(Container.DataItem,"IsHidden")) %>' />
                                        </td>
                                        <td class="options-width">

                                           <asp:HyperLink ID="Edit" title="Редактирай" class="icon-1 info-tooltip" runat="server"
                                                NavigateUrl='<%#"/admin/Content/EditDynamicContent.aspx?id=" + DataBinder.Eval(Container.DataItem,"ID")%>'>
                                            </asp:HyperLink>
                                            <asp:LinkButton ID="deleteButton" title="Направи неактивно" OnCommand="markInactiveButton_Click"
                                                CommandArgument='<%#Eval("ID") %>' runat="server" class="icon-2 info-tooltip"></asp:LinkButton>
                                            <asp:Label Visible="false" ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
                                            <asp:Label Visible="false" ID="TypeIDLabel" runat="server" Text='<%# Eval("TypeID") %>' />
                                        </td>
                                    </tr>
                                </ItemTemplate>
                                <AlternatingItemTemplate>
                                    <tr style="" class="alternate-row">
                                        <td>
                                            <asp:CheckBox ID="CheckBoxIsMarked" runat="server" />
                                        </td>
                                        <td>
                                            <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
                                        </td>
                                   
                                        <td>
                                            <asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date", "{0:D}") %>' />
                                        </td>
                                  
                                        <td>
                                            <asp:Label ID="TypeLabel" runat="server" Text='<%# Eval("TypeName") %>' />
                                        </td>
                                        <td>
                                            <asp:CheckBox ID="IsHiddenCheckBox" runat="server" Checked='<%# (DataBinder.Eval(Container.DataItem,"IsHidden")) %>' />
                                        </td>
                                        <td class="options-width">
                                             <asp:HyperLink ID="Edit" title="Редактирай" class="icon-1 info-tooltip" runat="server"
                                                NavigateUrl='<%#"/admin/Content/EditDynamicContent.aspx?id=" + DataBinder.Eval(Container.DataItem,"ID")%>'>
                                            </asp:HyperLink>
                                            <asp:LinkButton ID="deleteButton" title="Направи неактивно" OnCommand="markInactiveButton_Click"
                                                CommandArgument='<%#Eval("ID") %>' runat="server" class="icon-2 info-tooltip"></asp:LinkButton>
                                            <asp:Label Visible="false" ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
                                            <asp:Label Visible="false" ID="TypeIDLabel" runat="server" Text='<%# Eval("TypeID") %>' />
                                        </td>
                                    </tr>
                                </AlternatingItemTemplate>
                                
                            </asp:ListView>
                        </table>
                        <asp:DataPager ID="DataPagerListView" runat="server" PageSize="10" PagedControlID="itemsView">
                            <Fields>
                                <asp:NumericPagerField ButtonType="Link" NextPageText="" PreviousPageText="" ButtonCount="999999" />
                            </Fields>
                        </asp:DataPager>
                        </form>
                    </div>
                    <!--  end content-table  -->
                    <!--  start actions-box ............................................... -->
                    <div id="actions-box">
                        <a href="" class="action-slider"></a>
                        <div id="actions-box-slider">
                            <asp:LinkButton ID="MarkAllInactive" CssClass="action-edit" runat="server" OnCommand="markAllInactive_Click">Направи неактивни</asp:LinkButton>
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <!-- end actions-box........... -->
                    <div class="clear">
                    </div>
                </div>
                <!--  end content-table-inner ............................................END  -->
            </td>
            <td id="tbl-border-right">
            </td>
        </tr>
        <tr>
            <th class="sized bottomleft">
            </th>
            <td id="tbl-border-bottom">
                &nbsp;
            </td>
            <th class="sized bottomright">
            </th>
        </tr>
    </table>
    <div class="clear">
        &nbsp;</div>
    <!--  end content -->
</asp:Content>
